<template>
  <div class="download flex-s flex flex-col">
    <img :src="imgSrc" alt="" />
  </div>
</template>

<script setup lang="ts">
import { getQrcde } from "@/api/service/utils";
import { downloadImage, uuid } from "@/utils/utils";
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";

const imgSrc = ref();
onMounted(() => {
  const route = useRoute();
  const { data } = route.query;
  let params = {
    data
  };
  getQrcde(params).then((res) => {
    let fileName = uuid().slice(0, 6) + ".png";
    imgSrc.value = res.data;
    downloadImage(res.data, fileName);
  });
});
</script>

<style lang="scss" scoped>
.download {
  width: 100vw;
  height: 100vh;
}
</style>
